<template>
	<view class="content-view">
		<view class="content-main">
			<view class="title">意见反馈</view>
			<view class="btn-view">
				<view class="btn-item">活动建议</view>
				<view class="btn-item">其他</view>
			</view>
			<!-- autoHeight -->
			<up-textarea v-model="value" placeholder="请留下您的宝贵意见或反馈" border="none"  ></up-textarea>
			<view class="image-view">
				<view v-for="(item,index) in fileUrl" :key="index" class="image-item">
					<up-image :show-loading="true" :src="item" width="80px" height="80px" @click="upload"></up-image>
					<up-icon name="close-circle-fill" class="close" size="18" @click="fileUrl.splice(index, 1)"></up-icon>
				</view>
				<view class="upload-view" @click="upload">
					<up-icon name="camera-fill" size="20" color="#D3D4D6"></up-icon>
				</view>
			</view>
		</view>
	</view>
	<view class="contact-info">
		<view class="title">联系方式</view>
		<view class="phone-view">
			<view class="qu">+86</view>
			<view class="phone">
				<up-input
				    placeholder="请输入"
					type="number"
				    v-model="phoneValue"
					border="none"
				  ></up-input>
			</view>
		</view>
	</view>
	<view class="commit-btn">
		<up-button text="提交" color="linear-gradient(to bottom, #E48E0E, #ED5D09)" shape="circle"></up-button>
	</view>
</template>

<script>
	import { getToken } from '@/utils/auth'
	import config from '@/config'
	
	export default {
		data() {
			return {
				value: '',
				phoneValue: '',
				fileUrl: []
			}
		},
		methods: {
			upload() {
				let that = this;
				uni.chooseImage({
					count: 9,
					sizeType: ['original', 'compressed'],
					sourceType: ['album', 'camera'],
					success(res) {
					  // console.log(tempFilePaths);
					  uni.showLoading({
						  title: '正在上传...'
						})
						res.tempFilePaths.forEach(item => {
						  uni.uploadFile({
							url: config.baseUrl + "/sys/file/upload?access_token=" + getToken(),
							filePath: item,
							header: {
							  'content-type': 'multipart/form-data'
							},
							name: 'file',
							success: function(checkres) { 
							  uni.hideLoading()
								let checkResult = JSON.parse(checkres.data);
								that.fileUrl.push(checkResult.data.url)
							  },
							})
						})
								  
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content-main {
		border: 1px solid #f5f5f5;
		border-radius: 20rpx;
		padding: 30rpx;
		.title{
			font-weight: 700;
			font-size: 30rpx;
			color: #363636;
			margin-bottom: 30rpx;
			    
		}
		.btn-view {
			display: flex;
			padding-bottom: 30rpx;
			border-bottom: 1px solid #f5f5f5;
			.btn-item {
				width: 200rpx;
				height: 70rpx;
				line-height: 70rpx;
				text-align: center;
				border-radius: 5rpx;
				background-color: #F7F7F7;
				color: #333333;
				font-size: 26rpx;
				margin-right: 20rpx;
				
			}
		}
	}
	.image-view {
		display: flex;
		flex-wrap: wrap;
		.image-item {
			position: relative;
			border: 1px solid #f5f5f5;
			border-radius: 5rpx;
			margin: 10rpx;
			.close {
				position: absolute;
				top: 4rpx;
				right: 4rpx;
			}
		}
	}
	.upload-view {
		background-color: #f2f2f2;
		border-radius: 5rpx;
		width: 160rpx;
		height: 160rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 10rpx;
	}
	.contact-info {
		padding: 30rpx 50rpx;
		.title {
			font-weight: 700;
			font-size: 30rpx;
			color: #363636;
			margin-bottom: 30rpx;
		}
		.phone-view {
			display: flex;
			align-items: center;
			.qu {
				width: 100rpx;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				border-radius: 5rpx;
				background-color: #F7F7F7;
				margin-right: 20rpx;
				font-size: 30rpx;
				color: #000000;
				font-weight: 700;
			}
			.phone {
				flex: 1;
				height: 80rpx;
				line-height: 80rpx;
				text-align: left;
				border-radius: 5rpx;
				padding-left: 20rpx;
				background-color: #F7F7F7;
				font-size: 30rpx;
				color: #000000;
				display: flex;
				align-items: center;
				font-weight: 700;
			}
		}
	}
	.commit-btn {
		padding: 100rpx 30rpx 0 30rpx;
	}
</style>